<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: mslaria $ ($Date: 2007/07/11 13:08:20 $)
// $RCSfile: functions_reports.php,v $ : $Revision: 1.3 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

/**
* Render the KB Report Grid
*/
function renderKBReportGrid($_articles, $reporttype)
{
	global $_SWIFT;

	?>
	<table width="100%"  border="0" cellspacing="1" cellpadding="3" class="tborder">
	<tr class="tabletitlerow">
	<td>&nbsp;<?=$_SWIFT["language"]["kbsubject"]?></td>
	<td width="150" align="center">&nbsp;<?=$_SWIFT["language"]["kbdate"]?></td>
	<td width="130" align="center">&nbsp;<?=$_SWIFT["language"]["kbarticlestatus"]?></td>
	<?
	if ($reporttype == "rating")
	{
	?>
	<td width="120" align="center">&nbsp;<?=$_SWIFT["language"]["kbrating"]?></td>
	<?
	} else if ($reporttype == "populararticles") {
	?>
	<td width="80" align="center">&nbsp;<?=$_SWIFT["language"]["kbviews"]?></td>
	<?
	} else if ($reporttype == "comments") {
	?>
	<td width="80" align="center">&nbsp;<?=$_SWIFT["language"]["kbcomments"]?></td>
	<?
	}
	?>
	</tr>
	<?
	foreach ($_articles as $key=>$val)
	{
		if ($val["articlestatus"] == ARTICLE_PUBLISHED)
		{
			$articlestatus = $_SWIFT["language"]["published"];
			$statusicon = "icon_topicyellow.gif";
		} else if ($val["articlestatus"] == ARTICLE_PRIVATE) {
			$articlestatus = $_SWIFT["language"]["private"];
			$statusicon = "icon_topicprivate.gif";
		} else if ($val["articlestatus"] == ARTICLE_DRAFT) {
			$articlestatus = $_SWIFT["language"]["draft"];
			$statusicon = "icon_topicdraft.gif";
		}

		?>
		<tr class="<?=getRowBG()?>">
		<td>&nbsp;<?='<img src="'. $_SWIFT["themepath"] .$statusicon.'" border="0" align="absmiddle" />&nbsp;'. iif($val["hasattachments"]==1, '<img src="'. $_SWIFT["themepath"] .'icon_paperclip.gif" border="0" align="absmiddle" />&nbsp;').iif($val["totalcomments"]>0, '<img src="'. $_SWIFT["themepath"] .'icon_comment.gif" border="0" align="absmiddle" />&nbsp;') .'<span class="smalltext"><a href="index.php?_m=knowledgebase&_a=editquestion&kbarticleid='. $val["kbarticleid"] .'">'. $val["subject"] .'</a></span>'?></td>
		<td width="150" align="center">&nbsp;<?=edate($_SWIFT["settings"]["dt_datetimeformat"], $record["articledateline"])?></td>
		<td width="130" align="center">&nbsp;<?

		echo $articlestatus;
		?></td>
		<?
		if ($reporttype == "rating")
		{
		?>
		<td width="120" align="center">&nbsp;<?='<img src="'. $_SWIFT["themepath"] . getRatingImage($val["articlerating"]) .'" border="0" />&nbsp;'?></td>
		<?
		} else if ($reporttype == "populararticles") {
		?>
		<td width="80" align="center">&nbsp;<?=intval($val["views"])?></td>
		<?
		} else if ($reporttype == "comments") {
		?>
		<td width="80" align="center">&nbsp;<?=intval($val["totalcomments"])?></td>
		<?
		}
		?>
		</tr>
		<?
	}
	?>
	</table>
	<?
}
?>